#ifndef SL_RENDERER_H_
#define SL_RENDERER_H_
#include <Windows.h>
#include <gl/GL.h>
#include <gl/GLU.h>
#include "Referenced.h"
#include "ref_ptr.h"
#include "StateGraph.h"
#include "RenderInfo.h"
#include "SceneView.h"

namespace sl
{
	class SL_EXPORT Renderer :public Referenced
	{

	public:
		// init the renderer 
		static Renderer *	Create( HWND hWnd, bool bFullScreen = false );

		// release the renderer
		static	void		Destroy( Renderer* pRenderer );

		// get the renderer device
		static Renderer *	GetRenderer() { return ms_pRenderer; };

		HDC					GetOpenglDC(){ return m_hDC; };

		HGLRC				GetOpenglRC(){ return m_hRC; };
		
		bool				Init( HWND hWnd, bool bFullScreen );

		void				ShutDown();

		void				RenderScene(sl::Camera * pCamera,sl::Node * pNodeData = NULL );

		void				RenderFrame();

		void				PostRenderFrame();

		void				PreRenderFrame();


		static sl::Renderer *		ms_pRenderer;
	private:

		HWND						m_hWnd;
		HDC							m_hDC;
		HGLRC						m_hRC;
		bool						m_bFullScreen;
		DEVMODE						m_oldDevMode;
		DEVMODE						m_curDevMode;

		// the scene view using to render data
		sl::ref_ptr<sl::SceneView>	m_rSceneView;
	
		Renderer(void);
		~Renderer(void);

	};

	typedef ref_ptr<Renderer>	RendererPtr;	
}

#endif
